$(document).ready(function(){
	var oEditors = [];
	// 에디터 생성
	nhn.husky.EZCreator.createInIFrame({
		oAppRef: oEditors,
		elPlaceHolder: "content",
		sSkinURI: "/sEditor/SmartEditor2Skin.html",
		fCreator: "createSEditor2",		
	});	
	
	function pasteHTMLDemo(){
		sHTML = "<span style='color:#FF0000'>이미지 등도 이렇게 삽입하면 됩니다.</span>";
		oEditors.getById["content"].exec("PASTE_HTML", [sHTML]);
	}

	function showHTML(){
		alert(oEditors.getById["content"].getIR());
	}
	
	
	$("#btn_libReg").click(function(){
		oEditors[0].exec("UPDATE_CONTENTS_FIELD", []);
		if(validateCheck()){
			if(confirm("등록하시겠습니까?")) {
			$("#libFrm").submit();
			}
		}
	});
	
	$("#btn_qnaReg").click(function(){
		oEditors[0].exec("UPDATE_CONTENTS_FIELD", []);
		if(validateCheck()){
			if(confirm("등록하시겠습니까?")) {
			$("#qnaFrm").submit();
			}
		}
	});
	
	
	$("#btn_cyberReg").click(function(){
		oEditors[0].exec("UPDATE_CONTENTS_FIELD", []);
		if(validateCheck()){
		if(confirm("등록하시겠습니까?")) {
			$("#cyberFrm").submit();
		}
		}
	});
	
	$("#btn_libModi").click(function(){
		oEditors[0].exec("UPDATE_CONTENTS_FIELD", []);
		if(validateCheck()){
		if(confirm("수정하시겠습니까?")) {
			$("#libModiFrm").submit();
		}
		}
	});
	$("#btn_qnaModi").click(function(){
		oEditors[0].exec("UPDATE_CONTENTS_FIELD", []);
		if(validateCheck()){
		if(confirm("수정하시겠습니까?")) {
			$("#qnaModiFrm").submit();
		}
		}
	});
	
	function validateCheck(){	
		
		if($("#title").val() == ''){
			alert('제목을 입력해주십시요');
			$("#title").focus();
			return false;
		}
		if($("#content").val() == ''){
			alert('내용을입력해주십시요');
			return false;
		}	
		return true;
	}
});